<%@page contentType="text/html" %>
<%@page pageEncoding="UTF-8" %>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j" %>
<%@taglib prefix="rich" uri="http://richfaces.org/rich" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Goodwill - Блокировка обмена</title>
    <link rel="stylesheet" href="resources/css/main.css"/>
    <link rel="stylesheet" href="resources/css/stylesheet.css"/>
    <link rel="stylesheet" type="text/css" href="resources/css/jquery.countdown.css">
    <script type="text/javascript" src="resources/js/jquery.plugin.js"></script>
    <script type="text/javascript" src="resources/js/jquery.countdown.js"></script>
    <script type="text/javascript">
        function reloadPage(){
            window.location.reload();
        }
    </script>
</head>
<body>
<f:view>
    <jsp:include page="menu.jsp"/>
    <jsp:include page="status.jsp"/>
    <h:form id="blockBlock">
        <h:panelGroup id="blockNotStarted" rendered="#{!BlockExchangeBean.blocked}">
        <h:panelGrid columns="2">
            <h:outputText value="Остановить обмен для "/>
            <h:selectOneMenu value="#{BlockExchangeBean.managerId}" styleClass="f_s">
                <f:selectItems value="#{BlockExchangeBean.allManagers}"/>
            </h:selectOneMenu>
            <h:outputText value="на срок"/>
            <h:selectOneMenu value="#{BlockExchangeBean.intervalId}" styleClass="f_s">
                <f:selectItems value="#{BlockExchangeBean.timeIntervals}"/>
            </h:selectOneMenu>
            <h:commandButton action="#{BlockExchangeBean.activateBlock}" value="Запустить блокировку" />
        </h:panelGrid>
        </h:panelGroup>
        <h:panelGroup id="blockStarted" rendered="#{BlockExchangeBean.blocked}">
            <h:outputText value="Блокировка установлена для #{BlockExchangeBean.managerForBlock}"/>
            <div id="defaultCountdown" style="width: 240px; height: 45px; margin-top: 15px; margin-bottom: 15px"></div>
            <h:commandButton action="#{BlockExchangeBean.deactivateBlock}" value="Отменить блокировку" />
        </h:panelGroup>
        <rich:jQuery selector="#defaultCountdown" query="countdown({until: +'#{BlockExchangeBean.sec}', format: 'yowdHMS', onExpiry: reloadPage})"/>
    </h:form>
</f:view>
</body>
</html>